<?php 
	session_start(); 
	if (!$_SESSION["id_no"])
    {
        Header("Location: index.php");
    }
	else{
		if ($_SESSION['account_type']=='root'){
			$header="secured/header_login";
			$admin="yes";
		}
		elseif($_SESSION['account_type']=='Admin'){ 
			$header="secured/header_login";
			$admin="yes";
		}else{
			$header="header";
			$admin="no";
		}
	}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Ralimo System Panel</title>
<link rel="stylesheet" href="css/screen.css" type="text/css" media="screen" title="default" />
<link rel="stylesheet" href="css/jquery-ui-1.8.21.custom.css" type="text/css" media="screen" title="default" />
<!--[if IE]>
<link rel="stylesheet" media="all" type="text/css" href="css/pro_dropline_ie.css" />
<![endif]-->
<!--  jquery core -->
<script src="js/jquery/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/jquery/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>
<!--  date picker script -->
<link rel="stylesheet" href="css/datePicker.css" type="text/css" />
<script type="text/javascript" src="js/jquery/infowindow.js"></script>
</head>
<body> 
<?php 
	include"template/$header.php"; 
	include("query/db_connection.php");	
	
	if(isset($_POST['button'])){
		require("query/db_connection.php");
	
		$affiliate_id 	 = $_POST['affiliate_id'];
		$company_name 	 = $_POST['company_name'];
		$company_address = $_POST['company_address'];
		$company_email	 = $_POST['company_email'];
		$country_name	 = $_POST['country_name'];
		$contact_number	 = $_POST['contact_number'];
		
		$sql = "UPDATE affiliate 
				SET companyname='$company_name', 
					companyaddress='$company_address', 
					companyemail='$company_email', 
					landline='$contact_number'
				WHERE affiliateid = '$affiliate_id'";
		mysql_query($sql);
		echo "<script type='text/javascript'>
				window.location.replace('panel.php?page=affiliate');
			 </script>";
	}

?>
  <div class='clear'></div>
<!-- start content-outer ........................................................................................................................START -->
	<div id='content-outer'>
	<!-- start content -->
	<div id='content'>

	<!--  start page-heading -->
	<div id='page-heading'>
		<h1>Edit Affiliate</h1>
	</div>
	<!-- end page-heading -->
	
	<div id="back_affiliate" style="margin-left:1140px; width:100px;">
		<a href="panel.php?page=affiliate"><img src="images/forms/back.png" /></a>
	</div>

	<table border='0' width='100%' cellpadding='0' cellspacing='0' id='content-table'>
	<tr>
		<th rowspan='3' class='sized'><img src='images/shared/side_shadowleft.jpg' width='20' height='300' alt='' /></th>
		<th class='topleft'></th>
		<td id='tbl-border-top'>&nbsp;</td>
		<th class='topright'></th>
		<th rowspan='3' class='sized'><img src='images/shared/side_shadowright.jpg' width='20' height='300' alt='' /></th>
	</tr>
	<tr>
		<td id='tbl-border-left'></td>
		<td>
		<!--  start content-table-inner ...................................................................... START -->
		<div id='content-table-inner'>
						<!--  start step-holder -->
			
		<div style="color:#4B4B4B;font-size:13px;"><b>Change Affiliate Information:</b></div>
		<br />
		<br />
		<!--  end step-holder -->
		<!--  start table-content  -->
			<div id='table-content'>
				<form action="" method="post">
					<table border="0" cellpadding="0" cellspacing="0"  id="id-form">
						<tr>
							<td><b>Company Name:&nbsp;</b></td>
							<td><input type="text" name="company_name" autocomplete="off" class="inp-form" value="<?php echo $_GET['cmpyname'];?>" /></td>
						</tr>
						<tr>
							<td><b>Company Address:&nbsp;</b></td>
							<td><input type="text" name="company_address" autocomplete="off" class="inp-form" value="<?php echo $_GET['cmpyadd'];?>" /></td>
						</tr>
						<tr>
							<td><b>Company Email:&nbsp;</b></td>
							<td><input type="text" name="company_email" autocomplete="off" class="inp-form" value="<?php echo $_GET['cmpyemail'];?>"/></td>
						</tr>
						<tr>
							<td><b>Country Name:&nbsp;</b></td>
							<td><input type="text" name="country_name" autocomplete="off" disabled class="inp-form" value="<?php echo $_GET['ctryname'];?>" /></td>
						</tr>
						<tr>
							<td><b>Contact Number:&nbsp;</b></td>
							<td><input type="text" name="contact_number" autocomplete="off" class="inp-form" value="<?php echo $_GET['cnum'];?>" /></td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td><input id="button" name="button" type="submit" class="form_update" /></td>
							<input type="hidden" name="affiliate_id" value="<?php echo $_GET['id'];?>" />
						</tr>
					</table>
				</form>	
			<!--  start related-activities -->
			<div id="related-activities" style="margin-top:-280px;">
				
				<!--  start related-act-top -->
				<div id="related-act-top">
				<img src="images/forms/step_bar.png" width="271" height="43" alt="" />
				</div>
				<!-- end related-act-top -->
				
				<!--  start related-act-bottom -->
				<div id="related-act-bottom">
				
					<!--  start related-act-inner -->
					<div id="related-act-inner">
					
						<div class="left"><a href=""><img src="images/forms/icon_edit.gif" width="21" height="21" alt="" /></a></div>
						<div class="right">
							<h5>Editing an affiliate:</h5><br>
							<ul class="greyarrow">
								<li>First, Input the correct and exact date into the fields to avoid Re-editing of data.</li>
								<li>Second, Click the update button, once the editing of data is done.</li>
							</ul>
						</div>
						
						<div class="right" style="color:red;">
							<h5>Note:</h5>
							<p style="text-indent:20px; width:250px;">The Country fields in not editable, call an IT personel when this problem occurs.</p>
						</div>
						
						<div class="clear"></div>
					</div>
					<!-- end related-act-inner -->
					<div class="clear"></div>
				
				</div>
				<!-- end related-act-bottom -->
			
			</div>
			<!-- end related-activities -->

		</td>
		<td id="tbl-border-right"/>
	</tr>
	
	<tr>
		<th class='sized bottomleft'></th>
		<td id='tbl-border-bottom'>&nbsp;</td>
		<th class='sized bottomright'></th>
	</tr>
	</table>
	<div class='clear'>&nbsp;</div>

	</div>
	<!--  end content -->
	<div class='clear'>&nbsp;</div>
	</div>
	<!--  end content-outer........................................................END -->";
				
<!--  start nav-outer-repeat................................................... END -->

  <div class="clear"></div>
 
<!-- start content-outer ........................................................................................................................START -->
<div id="content-outer">
<!-- start content -->
<!--  end content -->
<div class="clear">&nbsp;</div>
</div>
<!--  end content-outer........................................................END -->

<div class="clear">&nbsp;</div>
    
<?php include"template/footer.php"; ?>
 
</body>
</html>


